#ifndef POLYGON
#define POLYGON

#include "contour.h"
#include <vector>
#include <iostream>
#include <iosfwd>

struct polygon_t;

typedef std::vector<contour_data_t> polygon_data_t;

point_t * find(point_t const & point, polygon_data_t & polygon_data);

point_t top_left_corner(polygon_data_t const & polygon_data);
point_t bottom_right_corner(polygon_data_t const & polygon_data);

polygon_t get_polygon(polygon_data_t const & polygon_data);

std::ostream & operator<< (std::ostream & out, polygon_data_t const & polygon_data);
std::istream & operator>> (std::istream & in, polygon_data_t & polygon_data);


struct polygon_t
{
    polygon_t ();
    
    template <class FwdIter>
       polygon_t (FwdIter p, FwdIter q)
          : contours_(p, q)
    {}

    void add (contour_t const & ring);
	void clear();

    contour_t const & operator[] (size_t i) const;
	size_t size() const;

    friend std::ostream & operator<< (std::ostream & out, polygon_t const & polygon);
    friend std::istream & operator>> (std::istream & in, polygon_t & polygon);
private:
    std::vector<contour_t> contours_;
};


#endif
